package com.ruoyi.report.service.impl;

import java.util.List;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.framework.web.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.report.mapper.ReportRefineryInfoMapper;
import com.ruoyi.report.domain.ReportRefineryInfo;
import com.ruoyi.report.service.IReportRefineryInfoService;

/**
 * 炼厂信息Service业务层处理
 * 
 * @author scp
 * @date 2024-10-11
 */
@Service
public class ReportRefineryInfoServiceImpl implements IReportRefineryInfoService 
{
    @Autowired
    private ReportRefineryInfoMapper reportRefineryInfoMapper;
    @Autowired
    private TokenService tokenService;

    /**
     * 查询炼厂信息
     * 
     * @param id 炼厂信息ID
     * @return 炼厂信息
     */
    @Override
    public ReportRefineryInfo selectReportRefineryInfoById(Long id)
    {
        return reportRefineryInfoMapper.selectReportRefineryInfoById(id);
    }

    /**
     * 查询炼厂信息列表
     * 
     * @param reportRefineryInfo 炼厂信息
     * @return 炼厂信息
     */
    @Override
    public List<ReportRefineryInfo> selectReportRefineryInfoList(ReportRefineryInfo reportRefineryInfo)
    {
        return reportRefineryInfoMapper.selectReportRefineryInfoList(reportRefineryInfo);
    }

    /**
     * 新增炼厂信息
     * 
     * @param reportRefineryInfo 炼厂信息
     * @return 结果
     */
    @Override
    public int insertReportRefineryInfo(ReportRefineryInfo reportRefineryInfo)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        reportRefineryInfo.setCreateBy(loginUser.getUser().getUserName());
        reportRefineryInfo.setDeptId(loginUser.getUser().getDeptId());
        reportRefineryInfo.setCreateTime(DateUtils.getNowDate());
        return reportRefineryInfoMapper.insertReportRefineryInfo(reportRefineryInfo);
    }

    /**
     * 修改炼厂信息
     * 
     * @param reportRefineryInfo 炼厂信息
     * @return 结果
     */
    @Override
    public int updateReportRefineryInfo(ReportRefineryInfo reportRefineryInfo)
    {
        LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
        reportRefineryInfo.setUpdateBy(loginUser.getUser().getUserName());
        reportRefineryInfo.setUpdateTime(DateUtils.getNowDate());
        return reportRefineryInfoMapper.updateReportRefineryInfo(reportRefineryInfo);
    }

    /**
     * 批量删除炼厂信息
     * 
     * @param ids 需要删除的炼厂信息ID
     * @return 结果
     */
    @Override
    public int deleteReportRefineryInfoByIds(Long[] ids)
    {
        return reportRefineryInfoMapper.deleteReportRefineryInfoByIds(ids);
    }

    /**
     * 删除炼厂信息信息
     * 
     * @param id 炼厂信息ID
     * @return 结果
     */
    @Override
    public int deleteReportRefineryInfoById(Long id)
    {
        return reportRefineryInfoMapper.deleteReportRefineryInfoById(id);
    }
}
